//数组中的第K个最大元素
class Solution {
    struct comp {
        bool operator()(int& x, int& y) { return x > y; }
    };

public:
    int findKthLargest(vector<int>& nums, int k) {
        priority_queue<int, vector<int>, comp> q;
        for (int i = 0; i < k; i++) {
            q.push(nums[i]);
        }
        for (int i = k; i < nums.size(); i++) {
            q.push(nums[i]);
            q.pop();
        }
        return q.top();
    }
};
